<!DOCTYPE HTML>
<html>
<head th:include="/common/head :: head">
</head>
<body class="pos-r">
<div >
	<nav class="breadcrumb" th:include="/common/navbar :: navbar('文章管理','文章管理列表')"></nav>
	<div class="page-container">
		<div class="col-sm-12">
			<form action="/article/list" method="post" id="searchForm">
			<div class="col-sm-4" th:include="/common/datebetween :: datebetween('发布时间','publishTime',${entity.publishTime},'publishTimeEnd',${entity.publishTimeEnd})"></div>
			<div class="col-sm-4" th:include="/common/inputbetween :: inputbetween('访问量','pageView',${entity.pageView},'pageViewEnd',${entity.pageViewEnd})"></div>
			<div class="col-sm-4">
				<input class="btn btn-primary radius" type="submit" value="搜索" />&nbsp;
				<input class="btn btn-primary radius" type="button" value="重置" onclick="doFormReset('searchForm')"/>
			</div>
			</form>
		</div>
		<div class="col-sm-12">
		<div class="cl pd-5 bg-1 bk-gray mt-20 col-sm-12"> <span class="l"> <a class="btn btn-primary radius" onclick="show('发布文章','/article/form')" href="javascript:;"><i class="Hui-iconfont">&#xe600;</i> 发布文章</a></span> <span class="r">共有数据：<strong th:text="${count}">54</strong> 条</span> </div>
		</div>
		<div class="col-sm-12">
		<div class="mt-20">
			<table class="table table-border table-bordered table-bg table-hover table-sort">
				<thead>
					<tr class="text-c">
						
						<th >标题</th>
						<th width="100">类别</th>
<!-- 						<th width="100">标签</th> -->
						<th width="200">发布时间</th>
						<th width="100">访问量</th>
						<th width="100">发布情况</th>
						<th width="100">操作</th>
					</tr>
				</thead>
				<tbody>
					<tr class="text-c va-m" th:each="vo,voStat : ${list}">
						
						<td class="text-l" th:text="${vo.title}"></td>
						<td class="text-l" th:text="${vo.category.name}"></td>
<!-- 						<td class="text-l" > -->
<!-- 							<span th:if="${vo.label}" th:text="${vo.label.name}"></span> -->
<!-- 						</td> -->
						<td class="text-l" th:text="${vo.publishTime!=null?#dates.format(vo.publishTime,'yyyy-MM-dd HH:mm:ss'):''}"></td>
						<td class="text-l" th:text="${vo.pageView}"></td>
						<td class="td-status"><span class="label label-success radius" th:text="${vo.publishStatus.value}">已发布</span></td>
						<td class="td-manage">
							<a style="text-decoration:none" class="ml-5" th:onclick="'javascript:del(\''+${vo.id}+'\');'" href="javascript:;" title="删除"><i class="Hui-iconfont">&#xe6e2;</i></a>
							<a style="text-decoration:none" class="ml-5" th:onclick="'javascript:toShow(\'查看文章\',\'/article/view\',\''+${vo.id}+'\');'" href="javascript:;" title="查看"><i class="Hui-iconfont">&#xe725;</i></a>
							<a style="text-decoration:none" class="ml-5" th:onclick="'javascript:toShow(\'修改文章\',\'/article/form\',\''+${vo.id}+'\');'" href="javascript:;" title="修改"><i class="Hui-iconfont">&#xe6df;</i></a> 
							<a th:if="${vo.publishStatus.value == '已发布' }" style="text-decoration:none" class="ml-5" th:onclick="'javascript:cancelPublish(\''+${vo.id}+'\');'" href="javascript:;" title="下架"><i class="Hui-iconfont">&#xe6de;</i></a> 
						</td>
					</tr>
				</tbody>
			</table>
		</div>
		</div>
	</div>
</div>


<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="/lib/zTree/v3/js/jquery.ztree.all-3.5.min.js"></script>
<script type="text/javascript" src="/lib/My97DatePicker/4.8/WdatePicker.js"></script> 
<script type="text/javascript" src="/lib/datatables/1.10.0/jquery.dataTables.min.js"></script> 
<script type="text/javascript" src="/lib/laypage/1.2/laypage.js"></script>
<script type="text/javascript">

$(function(){
	$('.table-sort').dataTable({
		"aaSorting": [[ 0, "desc" ]],//默认第几个排序
		"bStateSave": true,//状态保存
		"aoColumnDefs": [
		  {"orderable":false,"aTargets":[6]}// 制定列不参与排序
		]
	});
	
});

function del(id){
	layer.confirm('确认要删除吗？',function(index){
		$.ajax({
			type: 'POST',
			url: '/article/delete?id='+id,
			dataType: 'text',
			success: function(data){
				if(data){
					layer.msg('删除成功!',{icon:1,time:1000},function(){
						window.parent.location.reload();
					});
				}else{
					layer.msg('删除失败!'+data,{icon:2,time:1000});
				}
			},
			error:function(data) {
				console.log(data.msg);
			},
		});		
	});
}
function cancelPublish(id){
	layer.confirm('确认要取消发布吗？',function(index){
		$.ajax({
			type: 'POST',
			url: '/article/cancelPublish?id='+id,
			dataType: 'text',
			success: function(data){
				if(data){
					layer.msg('取消成功!',{icon:1,time:1000},function(){
						window.parent.location.reload();
					});
				}else{
					layer.msg('取消失败!'+data,{icon:2,time:1000});
				}
			},
			error:function(data) {
				console.log(data.msg);
			},
		});		
	});
}
</script>
</body>
</html>